%
If Not Sess_Array(48) = Session.SessionID then
UpdateSessions False
Response.Redirect "default.asp"
End If
set_partition = 500
Server.ScriptTimeout = 10000
objConn.CommandTimeout = 2000
If Application("Total_Elist" & strUnique) = Empty then
set rs = objConn.Execute("SELECT ID FROM " & tablUPfx & "User WHERE (elist = 1);")
If rs.EOF then
Application("Total_Elist" & strUnique) = 0
Else
rsdata = rs.getrows
Application("Total_Elist" & strUnique) = UBound(rsdata,2) + 1
Erase rsdata
End If
rs.close
End If
If Application("Sent_Elist" & strUnique) = Empty then
set rs = objConn.Execute("SELECT ID FROM " & tablUPfx & "User WHERE (elist = 1 AND issent = 1);")
If rs.EOF then
Application("Sent_Elist" & strUnique) = 0
Else
rsdata = rs.getrows
Application("Sent_Elist" & strUnique) = UBound(rsdata,2) + 1
Erase rsdata
End If
rs.close
End If
Dim title, subject, body, ID, isHTML
If Request.Querystring.Count = 1 then
showTempl = Request.Querystring.Item(1)
End If
If Request.Form("Flag") = 1 then
newsTemplate = showTempl
strTempl = "SELECT " & tablPfx & "Template.subject," & tablPfx & "Template.body FROM " & tablPfx & "Template WHERE " & tablPfx & "Template.tname='" & newsTemplate & "';"
set rs = objConn.Execute(strTempl)
If not rs.EOF then
uSubject = rs(0)
uBody = rs(1)
rs.close
uBody = Replace(uBody, ":MyWeb:", web_site)
uBody = Replace(uBody, ":WebNm:", web_name)
uBody = Replace(uBody, ":Date:", Now)
If Request.Form("isHTML") = 1 then isHTML = True
Set re = New RegExp
re.Global = False
re.IgnoreCase = False
re.pattern = "(?::top\d+:)"
If re.test(uBody) then
Set match_var = re.Execute(uBody)(0)
match_var = Replace(match_var, ":", "")
match_var = Replace(match_var, "top", "", 1, 1, 1)
If IsNumeric(match_var) then
uBody = Replace(uBody, ":""top" & match_var & ":", "", 1, 1, 1)
T = 1
If mysql then
strSQL = "SELECT subject, adID FROM " & tablPfx & "Ads WHERE (status = 1) ORDER BY pdate DESC LIMIT 0," & match_var & ";"
Else: strSQL = "SELECT TOP " & match_var & " subject, adID FROM " & tablPfx & "Ads WHERE (status = 1) ORDER BY pdate DESC;"
End If
set rs = objConn.Execute(strSQL)
If not rs.EOF then
If isHTML then strPop = "
"
Do While not rs.EOF
If T > match_var then Exit Do
title = rs(0)
If isHTML then
strPop = strPop & "
"
Else: strPop = strPop & " " & title & vbcr & " " & web_site & "viewad.asp?id=" & rs(1) & vbcr & vbcr
End If
rs.MoveNext
T = T + 1
Loop
If isHTML then strPop = strPop & "
"
End If
rs.close
End If
If Len(strPop) > 0 then uBody = re.Replace(uBody, strPop)
End If
uSubject = Replace(uSubject, ":WebNm:", web_name, 1, 1, 1)
If Request.Form("test") = "1" then
uBody = Replace(uBody, ":uEmail:", admin_email, 1, 1, 1)
uBody = Replace(uBody, ":uNick:", "Admin", 1, 1, 1)
uSubject = Replace(uSubject, ":uNick:", "Admin", 1, 1, 1)
Call sendEmail(admin_email, notify_email, uSubject, uBody)
Response.Write "
The current TEST News Letter was Emailed to the Email specified as 'Admin Email'.
"
Else
If mysql then
strSQL = "SELECT email,nick,credits,userID FROM " & tablUPfx & "User WHERE (elist = 1 AND issent = 0) LIMIT 0," & set_partition & ";"
Else: strSQL = "SELECT TOP " & set_partition & " email,nick,credits,userID FROM " & tablUPfx & "User WHERE (elist = 1 AND issent = 0);"
End If
set rs = objConn.Execute(strSQL)
If not rs.EOF then
nsdata = rs.getrows
rs.close
For nuser = 0 to UBound(nsdata,2)
uEmail = CryptText(nsdata(0, nuser), key, True)
uNick = nsdata(1, nuser)
uCred = nsdata(2, nuser)
userID = CLng(nsdata(3, nuser))
sBody = Replace(uBody, ":uEmail:", uEmail, 1, 1, 1)
sBody = Replace(sBody, ":uNick:", uNick, 1, 1, 1)
sBody = Replace(sBody, ":adCred:", uCred, 1, 1, 1)
sSubject = Replace(uSubject, ":uNick:", uNick, 1, 1, 1)
Call sendEmail(uEmail, notify_email, sSubject, sBody)
objConn.Execute("UPDATE " & tablUPfx & "User SET issent = 1 WHERE userID = " & userID & ";")
Application("Sent_Elist" & strUnique) = Application("Sent_Elist" & strUnique) + 1
Next
Response.Write "
The NewsLetter was Emailed to the next " & set_partition & " users from Email List.
"
Erase nsdata
Else
rs.close
Response.Write "
There are no users in Email list or current NewsLetter was already sent to everyone.
"
End If
End If
Else: Response.Write "
Template cannot be found!
"
End If
End If
strTempl = "SELECT " & tablPfx & "Template.* from " & tablPfx & "Template WHERE type=2;"
set rs = objConn.Execute(strTempl)
Do while not rs.EOF
template = rs("tname")
Select Case showTempl
Case ""
showTempl = template
getTheRest
strTemplate = ""
Case else
If showTempl = template then
getTheRest
strTemplate = strTemplate & ""
Else: strTemplate = strTemplate & ""
End If
End Select
rs.MoveNext
Loop
rs.close
Sub getTheRest()
title = rs("title")
subject = rs("subject")
body = rs("body")
If Not Application("isHTML" & strUnique) = "1" then
body = Server.HTMLEncode(body)
body = Replace(body, vbCrLf, " ")
End If
ID = rs("ID")
End Sub
%>